
/**
* javaScript
*
* Gonglong 2013.07.24
**/

/** from 163.com --start **/

function ajaxAction() {
	$("#ajaxBtn").click(function(e){
		$.get("ajaxAction?hidUsername=NAMEGet",function(data,status){
			// alert("Data: " + data + "\nStatus: " + status);
			$("#ajaxText").text(data);
		});
	});
	
	$("#ajaxBtn_post").click(function(e){
		var name = $("#hidSession").val();
		
		var postUrl = "ajaxAction?hidUsername=" + name;
		$.post(postUrl,{
			name:'NAMEEE'
		},function(data,status){
			// alert("Data: " + data + "\nStatus: " + status);
			$("#ajaxText").html(data);
		});
	});
}

function setJqgridData() {
	jQuery("#jqgrid_tb").jqGrid({
		datatype: "local",
		height: 230,
	   	colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
	   	colModel:[
	   		{name:'id',index:'id', width:60, sorttype:"int"},
	   		{name:'invdate',index:'invdate', width:90, sorttype:"date"},
	   		{name:'name',index:'name', width:100},
	   		{name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
	   		{name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},		
	   		{name:'total',index:'total', width:80,align:"right",sorttype:"float"},		
	   		{name:'note',index:'note', width:150, sortable:false}		
	   	],
	   	multiselect: false,
		pager: '#pager',
		rowNum:10,
	   	rowList:[10,20,30],
		sortname: 'id',
	   	caption: "Manipulating Array Data"
	}).navGrid("#pager",{edit:false,add:false,del:false});
	var mydata = [
			{id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
			{id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
			{id:"3",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
			{id:"4",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
			{id:"5",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
			{id:"6",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
			{id:"7",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
			{id:"8",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
			{id:"9",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
			{id:"10",invdate:"2008-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
			{id:"11",invdate:"2009-09-01",name:"test4",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
			{id:"12",invdate:"2010-09-01",name:"test5",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}
			];
	for(var i=0;i<=mydata.length;i++){
		jQuery("#jqgrid_tb").jqGrid('addRowData',i+1,mydata[i]);
		}
}

function setJqgridData_json() {
	
	jQuery("#jqgrid_json").jqGrid({
		datatype: "json",
		method : 'POST',
		url:"test.do?reqCode=jqgridJsonDemo",
		height: "auto",
		postData:{loginuserid:"10000001"},//developer用户ID
		width : 750,
	   	colNames:['Inv No', 'Client'],
	   	colModel:[
	   		{name:'no',index:'no', width:60, sorttype:"int"},
	   		{name:'busynessName',index:'busynessName', width:100}	
	   	],
	   	jsonReader:{
	   		root : "dataroot",
	   		records: "totalrecords",
	   		page: "currpage",
	   		total: "totalpages",
	   		repeatitems : false
	   		},
	   	viewrecords : true,
	   	multiselect: false,
		pager: '#pager2',
		rowNum:10,
	   	rowList:[10,20,30],
		sortname: 'no',
	   	caption: "jQGrid json Demo"
	}).navGrid("#pager2",{edit:false,add:false,del:false});

}

function indexValidate() {
	$("#loginForm").validate({
		rules: {
			userName: "required",
			userpw: "required"
		},
		messages: {
			userName: "矮油，请输入下用户名呗。",
			userpw: "没有密码不能登陆诶。"
		}
	});
}



